/**
 * 自定义字段 - 选择区县
 */
Ext.define("PSI.Area.DistrictSelectField", {
			extend : "Ext.form.field.Trigger",
			alias : "widget.psi_districtselectfield",

			config : {},

			initComponent : function() {
				var me = this;
				me.__idValue = null;

				me.enableKeyEvents = true;

				me.callParent(arguments);

				me.on("keydown", function(field, e) {
							if (e.getKey() == e.BACKSPACE) {
								field.setValue(null);
								me.setIdValue(null);
								e.preventDefault();
								return false;
							}

							if (e.getKey() != e.ENTER && !e.isSpecialKey()) {
								me.onTriggerClick(e);
							}
						});
			},

			onTriggerClick : function(e) {
				var me = this;

				var form = Ext.create("PSI.Area.DistrictSelectForm", {
							parentForm : me
						});
				form.show();
			},

			setIdValue : function(id) {
				this.__idValue = id;
			},

			getIdValue : function() {
				return this.__idValue;
			},

			clearIdValue : function() {
				this.setValue(null);
				this.__idValue = null;
			},

			__setDistrictInfo : function(province, city, district) {
				var me = this;
				me.setIdValue(district.get("id"));
				me.setValue(province.get("name") + city.get("name")
						+ district.get("name"));
			}
		});